import java.util.Collections;
import java.util.LinkedList;

import org.forester.phylogeny.PhylogenyNode;

public class Phylum implements Comparable<Phylum> {
	private String scientificName;
	private int depth;
	private int numberOfExternalNodes;
	private int sumOfDistinctTaxonomies;
	private LinkedList<Phylum> subClades = new LinkedList<Phylum>();
	private PhylogenyNode phyloNode;
	
	public Phylum(String scientificName) {
		this.scientificName = scientificName;
		this.depth = 0;
		this.numberOfExternalNodes = 0;
		this.sumOfDistinctTaxonomies = 0;
	}
	
	public Phylum(String scientificName, int depth, int numberOfExternalNodes, int sumOfDistinctTaxonomies, PhylogenyNode phyloNode) {
		this.scientificName = scientificName;
		this.depth = depth;
		this.numberOfExternalNodes = numberOfExternalNodes;
		this.sumOfDistinctTaxonomies = sumOfDistinctTaxonomies;
		this.phyloNode = phyloNode;
	}
	
	public Phylum(String scientificName, int depth, int numberOfExternalNodes, int sumOfDistinctTaxonomies, Phylum subClade, PhylogenyNode phyloNode) {
		this.scientificName = scientificName;
		this.depth = depth;
		this.numberOfExternalNodes = numberOfExternalNodes;
		this.sumOfDistinctTaxonomies = sumOfDistinctTaxonomies;
		subClades.add(subClade);
		this.phyloNode = phyloNode;
	}
	
	public void setName(String scientificName) {
		this.scientificName = scientificName;
	}
	
	public void setDepth(int depth) {
		this.depth = depth;
	}
	
	public void setNumberOfExternalNodes(int numberOfExternalNodes) {
		this.numberOfExternalNodes = numberOfExternalNodes;
	}
	
	public void setSumOfDistinctTaxonomies(int sumOfDistinctTaxonomies) {
		this.sumOfDistinctTaxonomies = sumOfDistinctTaxonomies;
	}
	
	public void addSubCladeSource(Phylum subClade) {
		subClades.add(subClade);
		Collections.sort(subClades);
	}
	
	public void setPhylogenyNode(PhylogenyNode phyloNode) {
		this.phyloNode = phyloNode;
	}
	
	public String getName() {
		return this.scientificName;
	}
	
	public int getDepth() {
		return this.depth;
	}
	
	public int getNumberOfExternalNodes() {
		return this.numberOfExternalNodes;
	}
	
	public int getSumOfDistinctTaxonomies() {
		return this.sumOfDistinctTaxonomies;
	}
	
	public LinkedList<Phylum> getSubClades() {
		return this.subClades;
	}
	
	public PhylogenyNode getPhylogenyNode() {
		return this.phyloNode;
	}
	
	@Override
	public int compareTo(Phylum phyl) {
		return this.scientificName.compareTo(phyl.scientificName);
	}
}